package com.yanzhenjie.andserver.sample;

/**
 * 作者: Tao
 * 日期: 2023/2/20
 * 时间: 13:49
 * 描述: e7HTTP状态码 用户访问被禁止
 */
public enum ServerHttpCode {

    /**
     * 服务器成功返回用户请求的数据
     */
    SUCCESS(200, "Success", "success"),

    /**
     * 用户新建数据成功
     */
    SUCCESS_CREATED(201, "Created", "success created"),

    /**
     * 表示一个请求已经进入后台排队（异步任务）
     */
    SUCCESS_ACCEPTED(202, "Accepted", "success accepted"),

    /**
     * 用户删除数据成功
     */
    SUCCESS_DELETED(204, "Deleted", "success deleted"),

    /**
     * 用户发出的请求数据有错误
     */
    FAIL_BAD_REQUEST(400, "BadRequest", "The input parameter is not valid"),

    /**
     * 表示用户没有权限（令牌、用户名、密码错误）
     */
    FAIL_UNAUTHORIZED(401, "Unauthorized", "The user don't have permission"),

    /**
     * 表示用户得到授权（与401错误相对），但是访问是被禁止的
     */
    FAIL_FORBIDDEN(403, "Forbidden", "User access is prohibited"),

    /**
     * 表示用户请求的资源不存在
     */
    FAIL_NOT_FOUND(404, "NotFound", "The resource requested by the user does not exist"),

    /**
     * 请求行中指定的请求方法不能被用于请求相应的资源
     */
    FAIL_METHOD_NOT_ALLOWED(405, "HTTPMethodNotAllowed", "The request http method is not supported for this resource"),

    /**
     * 服务器遇到一个意外情况，无法完成请求
     */
    FAIL_INTERNAL_SERVER_ERROR(500, "InternalError", "The request has been failed due to some unknown error"),

    /**
     * 服务器资源暂时不可用
     */
    FAIL_SERVICE_UNAVAILABLE(503, "ServiceUnavailable", "The request has failed due to a temporary failure of the server");

    private final int code;
    private final String title;
    private final String detail;

    ServerHttpCode(int code, String title, String detail) {
        this.code = code;
        this.title = title;
        this.detail = detail;
    }

    public int getCode() {
        return code;
    }

    public String getTitle() {
        return title;
    }

    public String getDetail() {
        return detail;
    }
}
